package com.algorithm.singleton;

/**
 * Package: com.algorithm.singleton
 * Description: 单例【双重校验锁模式，线程安全】
 * User: wangchao
 * Date: 2018-04-25
 * Time: 15:49
 */
public class SingletonDoubleCheckLock {

    private volatile static SingletonDoubleCheckLock ourInstance ;

    private SingletonDoubleCheckLock() {
    }

    public static SingletonDoubleCheckLock getInstance() {

        if (ourInstance == null) {
            synchronized (SingletonDoubleCheckLock.class) {
                if(ourInstance == null){
                    ourInstance = new SingletonDoubleCheckLock();
                }
            }
        }
        return ourInstance;
    }

}
